var express = require('express');
var router = express.Router();
//表现层
//获取食品种类
const{getAll2,addOne2,getOne2,updateOne2,deleteOne2}=require("../service/categoryService")
router.get('/', async function(req, res, next) {
  res.send(await getAll2());
});
router.post('/',async (req,res,next)=>{
    res.send(await addOne2(req.body));
})
router.get("/:_id",async(req,res)=>{
  res.send(await getOne2(req.params))
})
//修改食品种类
router.put('/',async(req,res)=>{
  res.send(await updateOne2(req.body))
})

//删除食品种类
router.delete("/",async(req,res)=>{
  const cateId=req.body;
   return await deleteOne2(cateId)
})
module.exports = router;
